from rest_framework.serializers import ModelSerializer,SerializerMethodField
from course import models


class CateSerializer(ModelSerializer):
    class Meta:
        model = models.CategoryModel
        fields = ['id', 'name']


class CategorySerializer(ModelSerializer):
    son = CateSerializer(many=True)

    class Meta:
        model = models.CategoryModel
        fields = ['id', 'name', 'son']


class TeacherSerializer(ModelSerializer):
    class Meta:
        model = models.TeacherModel
        fields = ['name', 'image', 'jobtitle']


class CourseSerializer(ModelSerializer):
    teacher = TeacherSerializer()
    class Meta:
        model = models.CourseModel
        fields = '__all__'



